using System;
using System.Collections.Generic;
using Icms.Core.Model;
using Icms.Core.Repository;
using Icms.Core.Service;
using Icms.Data;

namespace Icms.Service
{
    public class AssignmentHistoryService: IAssignmentHistoryService
    {
        private readonly IReportRepo reportRepo;

        public AssignmentHistoryService()
        {
            reportRepo = new ReportRepo(new ConnectionFactory());
        }
        public IPageAbleResult<AssignmentHistory> GetPage(int page, int pageSize, CaseSearchCriteria criteria)
        {
            var parameters = new Dictionary<string, object>
                                 {
                                     {"Id_Courts", criteria.CourtId},
                                     {"CaseTypeID", criteria.TypeId},
                                     {"CaseTypeExamID", criteria.TypeExamId},
                                     {"CaseIndexID", criteria.IndexId},
                                     {"CaseNumber", criteria.Number},
                                     {"CreatedDateFrom", criteria.RegistrationFrom},
                                     {"CreatedDateTo", criteria.RegistrationTo},
                                     {"PartyTypeID", criteria.PartyTypeId},
                                     {"PersonLastName", criteria.LastName},
                                     {"PersonFirstName", criteria.FirstName},
                                     {"CaseReference", criteria.ReferenceNumber},
                                     {"PageNumber", page},
                                     {"PageSize", pageSize}
                                 };

            var result =reportRepo.GetAssignmentData(parameters);
            return result;

        }

        public IEnumerable<CaseAssignmentHistory> GetByCase(Guid caseId)
        {
            
            var parameters = new Dictionary<string, object>
                                 {
                                     {"CaseId", caseId}
                                 };
            
            return reportRepo.GetCaseAssignmentData(parameters);
        }
    }
}